package demo3;


class Student{
    public void test(){
        System.out.println("Student::test()");
    }
}

public class Test {
    public void  func(){

        //匿名内部类
        //new 外部类(){
        // 方法体
        // } .test();
        new Student(){
            @Override
            public void test() {
                System.out.println("重写test()方法");
            }
        }.test();

        Student student = new Student(){
            @Override
            public void test() {
                System.out.println("重写test()方法");
            }
        };
        student.test();

    }
}
